using FluentNHibernate.Cfg;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using SGMDev;

namespace SGMDev.Data_Extender
{
    public class CRUDActions
    {
        public void Add(object DataEntity)
        {
            using (ISession session = MySessionFactory.InstantiedSession().OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(DataEntity);
                    transaction.Commit();
                }
        }
        public void Update(object DataEntity)
        {
            using (ISession session = MySessionFactory.InstantiedSession().OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.SaveOrUpdate(DataEntity);
                    transaction.Commit();
                }
            }
        }

        public void Delete(object DataEntity)
        {
            using (ISession session = MySessionFactory.InstantiedSession().OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Delete(DataEntity);
                    transaction.Commit();
                }
            }
        }
    }
}
